<?php
/**
 * Created by PhpStorm.
 * User: palidin
 * Date: 2018/9/6
 * Time: 10:05
 */

namespace App\Providers;

use Fresh\Foundation\ErrorException;
use Fresh\Foundation\Provider;
use Fresh\Utils\Json;

class FactoryProvider extends Provider
{
    public function init()
    {
        $this->getDI()->factory("json", static function ($value) {
            try {
                return Json::decode($value);
            } catch (ErrorException $e) {
                return [];
            }

        });
    }
}